<?php 

namespace App\Listeners;
use Illuminate\Database\Events\QueryExecuted;


class SqlListener {
	/**
	* Create the event listener.
	*
	* @return void
	*/
	public function __construct() {
	//
	}
	/**
	* Handle the event.
	*
	* @param =QueryExecuted $event
	* @return void
	*/
	public function handle(QueryExecuted $event) {
    	// 在这里编写业务逻辑
        $sql = str_replace("?", "'%s'", $event->sql);
        $log = $sql;

        if (request()->route()->getName() != 'zbsuser.index.console'){
            $log = vsprintf($sql, $event->bindings);
        }
        // 记录日志/ 2M 分割一次日志
        journalFile('../dataLog/sql/' , $log , 2);
	}
}















 ?>